home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / usr_-_Usr_Files / SBIN / FLUSHPOP.SH < prev    next >
Linux/UNIX/POSIX Shell Script  |  1999-09-17  |  1KB  |  45 lines

  1. #!/bin/sh
  2. ##
  3. ## 8-1-97 Ian Kinner (ian@llc.net)
  4. ##
  5. ## Simple sh script to remove stale files left in the in.pop3d tmp 
  6. ## directory, which cause DoS for POP3 users. Should be run by a crontab
  7. ## every 15 minutes or so.
  8. ##
  9. ## Modified 2-10-1999 Patrick J. Volkerding (volkerdi@slackware.com)
  10. ##
  11.  
  12. # in.pop3d spool directory:
  13. TMPDIR=/var/spool/pop
  14. if [ ! -d $TMPDIR ]; then
  15.   exit
  16. fi
  17.  
  18. # Secure (non user-writable) location for temporary files:
  19. STMP=/var/log/setup/tmp
  20.  
  21. # Make secure TMP directory if it doesn't already exist:
  22. if [ ! -d $STMP ]; then
  23.   mkdir -p $STMP
  24.   chmod 700 $STMP
  25. fi
  26.  
  27. # Generate a list of users with POP files in $TMPDIR.  If these
  28. # users are not currently using POP, then they're locked out.
  29. ls -l $TMPDIR | awk '{print $9}' > $STMP/USERLIST
  30. NUMBER=`wc -l $STMP/USERLIST | awk '{print $1}'`
  31.  
  32. while [ $NUMBER -gt 1 ]; do
  33.   USER=`head -$NUMBER $STMP/USERLIST | tail -1`
  34.   if ps aux | grep in.pop3d | grep "^$USER " 1> /dev/null ; then # logged in
  35.     DONOTHING=true
  36.   else # stale lock file found
  37.     rm -f $TMPDIR/$USER
  38.     echo "flushpop.sh: stale POP file for $USER deleted" | logger
  39.   fi
  40.   NUMBER="`expr $NUMBER - 1`"
  41. done
  42.  
  43. rm -f $STMP/USERLIST
  44.  
  45.